package org.makcro.sms.services.chat.web.client.mvc;

import org.makcro.sms.services.chat.web.client.AppEvents;
import org.makcro.sms.services.chat.web.client.mvc.view.SubscriberTabView;

import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;

public class SubscribersTabController extends Controller {

	private SubscriberTabView	subscriberTabView;

	public SubscribersTabController() {
		registerEventTypes( AppEvents.SUBSCRIBERS_TAB_REQUESTED );
	}

	@Override
	protected void initialize() {
		super.initialize();
		this.subscriberTabView = new SubscriberTabView( this );
	}

	@Override
	public void handleEvent(AppEvent event) {
		EventType type = event.getType();

		if (type.equals( AppEvents.SUBSCRIBERS_TAB_REQUESTED )) {
			onSubscribersTabRequested( event );
		}
	}

	private void onSubscribersTabRequested(AppEvent event) {
		forwardToView( subscriberTabView, event );
	}

}
